<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>       
        
<script type="text/javascript">
   function deleteObject(id){
       if(confirm('Bạn chắc chắn muốn xóa ?')){
           var url = '${pageContext.request.contextPath}/employee/delete/'+id;
           window.location.href = url;
       }
   }
</script>
<div class="sub-content">
	<jsp:include page="form-search.jsp"></jsp:include> 
	<c:if test="${url_02.add eq 1}">
		<a href="${pageContext.request.contextPath}/employee/add">Thêm mới</a>    
	</c:if>
	<c:choose>
		<c:when test="${!empty objs}">	
			<table class="tb-content">
				<tr>
				    <th>Tên nhân viên</th>
				    <th>Điện thoại</th>			   
				    <th>Email</th>	
				    <th>Thành phố</th>			    
				    <th>&nbsp;</th>
				</tr>
				<c:forEach items="${objs}" var="obj">
				    <tr>
				        <td>${obj.empName} </td>
				        <td>${obj.empPhone}</td>		        
				         <td>
				         	<c:choose>
					        	<c:when test="${url_02.edit eq 1}">
					        		<a href="${pageContext.request.contextPath}/employee/edit/${obj.empId}">${obj.empMail}</a>
					        	</c:when>
					        	<c:otherwise>${obj.empMail}</c:otherwise>
					        </c:choose>		         
				         </td>
				         <td>${obj.cityId.cityName}</td>
				        <td>
					        <c:choose>
					        	<c:when test="${url_02.delete eq 1}">
					        		<a href="javascript: void(0)"  onclick="deleteObject(${obj.empId})">Xóa</a>
					        	</c:when>
					        	<c:otherwise>-</c:otherwise>
					        </c:choose>
				        </td>
				    </tr>
				</c:forEach>
			</table>
		</c:when>
		<c:otherwise>
			<p class="tb-empty"><spring:message code="label.tb.empty"/></p>
		</c:otherwise>
	</c:choose>  
</div>
 
